local skel = fk.CreateSkill {
  name = "emo__huangqi",
}

Fk:loadTranslationTable{
  ["emo__huangqi"] = "慌乞",
  [":emo__huangqi"] = "每回合限一次，你受到伤害时，可以随机执行以下项五次：1.翻面；2.横置；3.重置；4.弃置两张牌；5.回复1点体力。",

  ["#emo__huangqi-choose"] = "倾袭：你可以对1名手牌数等于你的角色造成1点伤害，令其执行1个出牌阶段。",

  ["$emo__huangqi1"] = "只要放过我，这些，都是你的。",
  ["$emo__huangqi2"] = "家有余财，愿尽献将军。",
}

skel:addEffect(fk.DamageInflicted, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
    and player:usedSkillTimes(skel.name) == 0
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    for _ = 1, 5 do
      if player.dead then break end
      local choices = {1, 2}
      if #table.filter(player:getCardIds("he"), function (id) return not player:prohibitDiscard(id) end) > 1 then
        table.insert(choices, 3)
      end
      if player:isWounded() then
        table.insert(choices, 4)
      end
      local rnd = table.random(choices)
      if rnd == 1 then
        player:turnOver()
      elseif rnd == 2 then
        player:setChainState(not player.chained)
      elseif rnd == 3 then
        room:askToDiscard(player, {min_num = 2, max_num = 2, include_equip = true, skill_name = skel.name, cancelable = false})
      else
        room:recover { num = 1, skillName = skel.name, who = player, recoverBy = player }
      end
      room:delay(200)
    end
  end,
})

return skel
